/* eslint-disable */
export  function isFetch() {
  if (navigator && navigator.userAgent) {
    // 检测浏览器版本，并设置 window.__disableNativeFetch 来决定是否开启 fetch
    var userAgent = navigator.userAgent || "";
    var appVersion = navigator.appVersion || "";
    var vendor = navigator.vendor || "";

    var ua = (userAgent + ' ' + appVersion + ' ' + vendor).toLowerCase();

    var match = /(chrome)[ \/]([\w.]+)/.exec(ua)
      || /(webkit)[ \/]([\w.]+)/.exec(ua)
      || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua)
      || /(msie) ([\w.]+)/.exec(ua)
      || /(trident)(?:.*? rv:([\w.]+)|)/.exec(ua)
      || ua.indexOf("compatible") < 0
      && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || [];

    var engine = match[0];
    var mainVersion = match[2].split('.')[0];

    // chrome 内核版本大于 46， firefox 版本大于39 才开启 fetch
    console.log(engine.indexOf('chrome'));
    console.log(engine);
    console.log(mainVersion);
    if (engine.indexOf('chrome') === 0 && mainVersion >= 46) {
      window.__disableNativeFetch = false;
      return false;
    } else if (engine.indexOf('mozilla') === 0 && mainVersion >= 39) {
      window.__disableNativeFetch = false;
      return false;
    } else {
      window.__disableNativeFetch = true;
      return true;
    }
  }
}
